package leung.java.hibernate;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

@Entity
@Table(name="card")
public class Card {
	
	private  int id;
	private String idcard;
	
	
	private User user;
	
	@Id
	@GeneratedValue(generator="mfg")
	@GenericGenerator(name="mfg",strategy="foreign",parameters=@Parameter(name="property",value="user"))
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getIdcard() {
		return idcard;
	}
	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}
	@OneToOne(optional=false,cascade=CascadeType.ALL)
	@PrimaryKeyJoinColumn
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
}
